<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <ul id='users'></ul>
</body>
<script>
    fetch("http://localhost:8081/getlist")
        .then(res => res.text())
        // 说明响应数据的结构
        .then(res => {
            console.log(res);
            var userList = res;
            var userList = JSON.parse(res);
            var users = document.getElementById("users");
            for (var i = 0; i < userList.length; i++) {
                var liNode = document.createElement("li");
                liNode.innerHTML = '<span>' + userList[i]['username'] +
                    "&nbsp;&nbsp;</span>" + "&nbsp;&nbsp;<span>" +
                    userList[i]['agent_name'] +
                    "</span>" + "&nbsp;&nbsp;<span>" +
                    userList[i]['choose'] + "</span>" +
                    "&nbsp;&nbsp;<a href='/del?deluser="+
                    userList[i]['username'] + "' >删除</a>";
                users.appendChild(liNode);
            }
        });
</script>

</html>